<?php
namespace Amis\functions;

use Amis\Basics\AmisBasics;

class DropDownButton extends AmisBasics
{
    public string $type = 'dropdown-button';


    public function label($label)
    {
        $this->label = $label;
        return $this;
    }

    public function className($className)
    {
        $this->className = $className;
        return $this;
    }

    public function btnClassName($btnClassName)
    {
        $this->btnClassName = $btnClassName;
        return $this;
    }

    public function menuClassName($menuClassName)
    {
        $this->menuClassName = $menuClassName;
        return $this;
    }

    public function block($block)
    {
        $this->block = $block;
        return $this;
    }

    public function lineStyle($type)
    {
        if (in_array($type, ['xs', 'sm', 'md', 'lg'])) {
            $this->lineStyle = $type;
        }
        return $this;
    }

    public function align($lineStyle = 'left')
    {
        $this->align = $lineStyle == 'left' ?: 'right';
        return $this;
    }

    public function buttons(...$buttons)
    {
        $this->set(__FUNCTION__,...$buttons);
        return $this;
    }

    public function iconOnly(bool $iconOnly = false)
    {
        $this->iconOnly = $iconOnly;
        return $this;
    }

    public function defaultIsOpened(bool $defaultIsOpened = false)
    {
        $this->defaultIsOpened = $defaultIsOpened;
        return $this;
    }

    public function closeOnOutside(bool $closeOnOutside = true)
    {
        $this->closeOnOutside = $closeOnOutside;
        return $this;
    }

    public function closeOnClick(bool $closeOnClick = false)
    {
        $this->closeOnClick = $closeOnClick;
        return $this;
    }

    public function trigger(string $trigger = 'click')
    {
        if (in_array($trigger, ['click', 'hover'])) {
            $this->trigger = $trigger;
        }
        return $this;
    }

    public function hideCaret(bool $hideCaret = false)
    {
        $this->hideCaret = $hideCaret;
        return $this;
    }
}